function checkArray(key) {
    let permissionList = localStorage.getItem(process.env.VUE_APP_USER_PERMS);
    permissionList = permissionList ? JSON.parse(permissionList) : []
    return permissionList.findIndex(item => item.perms === key) > -1
}

const permission = {
    inserted: function (el, binding) {
        // console.log('v-permission', binding);
        const permission = binding.value // 获取到 v-permission的值
        if (permission) {
            const hasPermission = checkArray(permission)
            if (!hasPermission) {
                // 没有权限 移除Dom元素
                el.parentNode && el.parentNode.removeChild(el)
            }
        }
    },
}

export default permission;
